import { FC } from 'react'
import type { QuestionTitleProps } from './types'
import { Typography } from 'antd'

export const QuestionTitleDefaultProps: QuestionTitleProps = { text: '一行标题', isCenter: false, level: 1 }

const QuestionTitle: FC<QuestionTitleProps> = props => {
  const { text = '', level, isCenter = false } = { ...QuestionTitleDefaultProps, ...props }

  function genFontSize(level: number) {
    if (level === 1) return '24px'
    if (level === 2) return '20px'
    if (level === 3) return '16px'
    return '16px'
  }

  return (
    <Typography.Title level={level} style={{ textAlign: isCenter ? 'center' : 'start', fontSize: genFontSize(level!) }}>
      {text}
    </Typography.Title>
  )
}

export default QuestionTitle
